package com.flymobi.mshop.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.flymobi.mshop.R;
import com.flymobi.mshop.activity.BuyShopping;
import com.flymobi.mshop.util.ImageUtil;
import com.flymobi.mshop.util.service.IService;

/**
 * 
 * @author 余鹏
 * 
 */
public class ImageViewAdapter extends BaseAdapter{

	private Context mContext;
	private String[] imagePathList;
	private String[] id;
	public ImageViewAdapter(
			Context c, 
			String[] imagePathList,
			String[] id) {
		mContext = c;
		this.imagePathList = imagePathList;
		this.id=id;
	}
	
	@Override
	public int getCount() {
		return Integer.MAX_VALUE;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	private ImageView image_gly;
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		convertView = View.inflate(mContext, R.layout.image_gallery, null);
		image_gly = (ImageView) convertView.findViewById(R.id.image_gly);
		if(imagePathList!=null){
			BitmapDrawable bm = new BitmapDrawable(ImageUtil.getHttpBitmap(IService.serverUrl + imagePathList[position % imagePathList.length]));
			image_gly.setImageDrawable(bm);
			image_gly.setScaleType(ImageView.ScaleType.FIT_XY);
			image_gly.setAdjustViewBounds(true);
			
		}
		return convertView;
	}

}
